import {LogHelper} from "../../utils/logHelper";

class PathfinderTask implements ICreepTask {
  public run(creep: Creep): void {
    if(creep.memory.targetRoom != undefined){
      let pos = new RoomPosition(25,25,creep.memory.targetRoom)
      let rangeToFlag = creep.pos.getRangeTo(pos);

      if(rangeToFlag > 1){
        creep.go(pos);
      }

    //   if(creep.room.name !== creep.memory.targetRoom){
    //     // 如果不在指定房间则移动到指定房间
    //     creep.go(new RoomPosition(25,25,creep.memory.targetRoom));
    //   }
    //   else {
    //     const room = Game.rooms[creep.memory.targetRoom];
    //     if(room){
    //       const controller = room.controller;
    //       if(controller){
    //         let rangeToFlag = creep.pos.getRangeTo(controller);
    //         if (rangeToFlag > 1) {
    //           // 如果 creep 不在旗帜附近，就移动到旗帜位置
    //           creep.go(controller);
    //         }
    //     }
    //   }
    // }
  }
}
}

export { PathfinderTask };